export default {
  namespaced: true, // 必须要划分空间，开发者必须要保证模块名是属性不一样
  state: {
    age: 30
  },
  mutations: { // 通过 $store.commit 触发该对象函数, 更改 state 的状态
    syncAdd(state, payload) {
      console.log('moduleB syncAdd mutations', payload)
      state.age += payload.age;
    },
    asyncMinus(state, payload) {
      console.log('moduleB asyncMinus mutations', payload)
      state.age -= payload.age;
    }
  },
  actions: { // 通过 $store.dispatch 触发该对象函数
    syncAdd({ commit }, payload) {
      setTimeout(() => {
        console.log('moduleB actions syncAdd setTimeout')
        commit('syncAdd', payload);
      }, 3000);
    },
    asyncMinus({ commit }, payload) {
      setTimeout(() => {
        console.log('moduleB actions asyncMinus setTimeout')
        commit('asyncMinus', payload);
      }, 3000);
    }
  },
  modules: {
    c: {
      namespaced: true, // 必须要划分空间，开发者必须要保证模块名是属性不一样
      state: { c: "moduleC" },
      modules: {
        d: {
          namespaced: true, // 必须要划分空间，开发者必须要保证模块名是属性不一样
          state: { d: "moduleD" }
        }
      }
    },
  }
}